package com.headwind.controller;

import cn.hutool.core.lang.Dict;
import com.headwind.entity.HwMood;
import com.headwind.service.MybatisHwMoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.CompletableFuture;

/**
 * @author : Headwind
 * @version : 1.0
 * @date : Created in 2020/8/10
 * @description : 访问控制类
 */
@RestController
@RequestMapping("/mybatis")
public class MybatisHwMoodController {
    private final MybatisHwMoodService moodService;

    @Autowired
    public MybatisHwMoodController(MybatisHwMoodService moodService) {
        this.moodService = moodService;
    }

    @GetMapping("/moods/{id}")
    public CompletableFuture<Dict> findAllMoods(@PathVariable String id) {
        return CompletableFuture.supplyAsync(() ->
                moodService.findAllMoods(id));
    }

    @PostMapping("/user/mood")
    public CompletableFuture<Dict> addMood(@RequestBody HwMood mood) {
        return CompletableFuture.supplyAsync(() ->
                moodService.addMood(mood));
    }
}
